package com.hp.entity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PowerTreeVo {

    private int id;
    private String text;
    private String state;
    private boolean checked=false;
    private String iconCls;
    private String parentid;
    private Map attributes = new HashMap<>();
    private List<PowerTreeVo> children = new ArrayList<>();

    public PowerTreeVo(Power p, List<Power> list){
        this.id=p.getId();
        this.text=p.getContent();
        this.state="open";

        //判断是否有资源
        for (Power power : list) {
            if(power.getId()==this.id){
                this.checked=true;
                continue;
            }
        }

        List<Power> powers = p.getPowers();
        if(powers!=null&&!powers.isEmpty()&&powers.size()>0){
            for (Power pp : powers) {
                this.children.add(new PowerTreeVo(pp, list));
            }
        }
    }


    private String getIcon() {
        String str="";
        if(parentid==null||parentid.equals("")){
            str="icon-resources";
        }else{
            str="icon-sys";
        }
        return str;
    }


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getParentid() {
        return parentid;
    }


    public void setParentid(String parentid) {
        this.parentid = parentid;
    }


    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public boolean isChecked() {
        return checked;
    }

    public void setChecked(boolean checked) {
        this.checked = checked;
    }


    public String getIconCls() {
        return iconCls;
    }


    public void setIconCls(String iconCls) {
        this.iconCls = iconCls;
    }


    public Map getAttributes() {
        return attributes;
    }

    public void setAttributes(Map attributes) {
        this.attributes = attributes;
    }

    public List<PowerTreeVo> getChildren() {
        return children;
    }

    public void setChildren(List<PowerTreeVo> children) {
        this.children = children;
    }


}
